<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/view/conf/farmtag.tld" prefix="PF"%>
<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'north',border:false">
		<form id="searchConfigerformForm">
			<table class="editTable">
				<tr>
					<td class="title">参数集:</td>
					<td colspan="5">${configer.name}</td>
				</tr>
				<tr>
					<td class="title">名称:</td>
					<td><input name="NAME:like" type="text" style="width: 140px;"></td>
					<td class="title">编码:</td>
					<td><input name="CODE:like" type="text" style="width: 140px;"></td>
					<td colspan="2"><a id="a_search" href="javascript:void(0)"
						class="easyui-linkbutton" iconCls="icon-search">查询</a> <a
						id="a_reset" href="javascript:void(0)" class="easyui-linkbutton"
						iconCls="icon-reload">清除条件</a></td>
				</tr>
			</table>
		</form>
	</div>
	<div data-options="region:'center',border:false">
		<table id="dataConfigerformGrid">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true"></th>
					<th field="NAME" data-options="sortable:true" width="20">名称</th>
					<th field="CODE" data-options="sortable:true" width="20">编码</th>
					<th field="SORT" data-options="sortable:true" width="10">排序</th>
					<th field="INNERCODE" data-options="sortable:true" width="10">入参</th>
					<th field="MODEL" data-options="sortable:true" width="10">模型</th>
					<th field="PCONTENT" data-options="sortable:true" width="30">备注</th>
				</tr>
			</thead>
		</table>
	</div>
	<div id="formToolbar">
		<c:if test="${configer.model=='NONE'}">
			<a class="easyui-linkbutton"
				data-options="iconCls:'icon-tip',plain:true,onClick:viewDataConfigerform">查看
			</a>
			<a class="easyui-linkbutton"
				data-options="iconCls:'icon-add',plain:true,onClick:addDataConfigerform">新增
			</a>
		</c:if>
		<a class="easyui-linkbutton"
			data-options="iconCls:'icon-edit',plain:true,onClick:editDataConfigerform">修改
		</a>
		<c:if test="${configer.model!='NONE'}">
			<a class="easyui-linkbutton"
				data-options="iconCls:'icon-blog--arrow',plain:true,onClick:initcform">初始化表单
			</a>
		</c:if>
		<c:if test="${configer.model=='NONE'}">
			<a class="easyui-linkbutton"
				data-options="iconCls:'icon-remove',plain:true,onClick:delDataConfigerform">删除
			</a>
		</c:if>
	</div>
</div>
<script type="text/javascript">
	var url_delActionConfigerform = "configerform/del.do";//删除URL
	var url_formActionConfigerform = "configerform/form.do";//增加、修改、查看URL
	var url_searchActionConfigerform = "configerform/query.do?configerId=${configer.id}";//查询URL
	var title_windowConfigerform = "配置表单管理";//功能名称
	var gridConfigerform;//数据表格对象
	var searchConfigerform;//条件查询组件对象
	$(function() {
		//初始化数据表格
		gridConfigerform = $('#dataConfigerformGrid').datagrid({
			url : url_searchActionConfigerform,
			fit : true,
			fitColumns : true,
			'toolbar' : '#formToolbar',
			pagination : true,
			closable : true,
			checkOnSelect : true,
			border : false,
			striped : true,
			rownumbers : true,
			ctrlSelect : true
		});
		//初始化条件查询
		searchConfigerform = $('#searchConfigerformForm').searchForm({
			gridObj : gridConfigerform
		});
	});
	//查看
	function viewDataConfigerform() {
		var selectedArray = $(gridConfigerform).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionConfigerform + '?pageset.pageType='
					+ PAGETYPE.VIEW + '&ids=' + selectedArray[0].ID;
			$.farm.openWindow({
				id : 'winConfigerform',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '浏览'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}
	//新增
	function addDataConfigerform() {
		var url = url_formActionConfigerform + '?operateType=' + PAGETYPE.ADD
				+ "&configerId=${configer.id}";
		$.farm.openWindow({
			id : 'winConfigerform',
			width : 600,
			height : 300,
			modal : true,
			url : url,
			title : '新增'
		});
	}
	//修改
	function editDataConfigerform() {
		var selectedArray = $(gridConfigerform).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionConfigerform + '?operateType='
					+ PAGETYPE.EDIT + '&ids=' + selectedArray[0].ID;
			$.farm.openWindow({
				id : 'winConfigerform',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '修改'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}

	//初始化表单
	function initcform() {
		$.messager.confirm(MESSAGE_PLAT.PROMPT, "本操作将删除并重置当前数据，是否继续？",
				function(flag) {
					if (flag) {
						$(gridConfigerform).datagrid('loading');
						$.post('configerform/initForms.do?configerId=${configer.id}', {}, function(
								flag) {
							var jsonObject = JSON.parse(flag, null);
							$(gridConfigerform).datagrid('loaded');
							if (jsonObject.STATE == 0) {
								$(gridConfigerform).datagrid('reload');
							} else {
								var str = MESSAGE_PLAT.ERROR_SUBMIT
										+ jsonObject.MESSAGE;
								$.messager.alert(MESSAGE_PLAT.ERROR, str,
										'error');
							}
						});
					}
				});
	}
	//删除
	function delDataConfigerform() {
		var selectedArray = $(gridConfigerform).datagrid('getSelections');
		if (selectedArray.length > 0) {
			// 有数据执行操作
			var str = selectedArray.length + MESSAGE_PLAT.SUCCESS_DEL_NEXT_IS;
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$(gridConfigerform).datagrid('loading');
					$.post(url_delActionConfigerform + '?ids='
							+ $.farm.getCheckedIds(gridConfigerform, 'ID'), {},
							function(flag) {
								var jsonObject = JSON.parse(flag, null);
								$(gridConfigerform).datagrid('loaded');
								if (jsonObject.STATE == 0) {
									$(gridConfigerform).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ jsonObject.MESSAGE;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
</script>